cmake_minimum_required (VERSION 2.6)
project (cmake3)
set (VERSION_MAJOR 3)
set (VERSION_MINOR 4)
set (tom cat CACHE STRING "cross directory")

option (LIB_VALID  "if include my lib ? " ON)

configure_file (
	"${PROJECT_SOURCE_DIR}/CmakeConfig.h.in"
	"${PROJECT_BINARY_DIR}/CmakeConfig.h"
  )

include_directories("${PROJECT_BINARY_DIR}")


if (LIB_VALID)
  include_directories ("${PROJECT_SOURCE_DIR}/Mylib")
  add_subdirectory (Mylib)
  set (EXTRA_LIBS hello Mylib)
  message("EXTRA------> ${EXTRA_LIBS}")	
endif (LIB_VALID)
 
add_executable (App main.cpp)
target_link_libraries (App  ${EXTRA_LIBS})


install (TARGETS App DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/CmakeConfig.h"        
         DESTINATION include)

# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE  
     "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
set (CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_VERSION_PATCH "9")
#无效SET(CPACK_PACKAGE_VERSION ${5.5.5})
#设置安装包的包名，打好的包将会是packagename-version-linux.deb，如果不设置，默认是工程名
set(CPACK_PACKAGE_NAME "cn.net.pikachu.bulbasaur")

#设置程序名，就是程序安装后的名字
set(CPACK_DEBIAN_PACKAGE_NAME "bulbasaur")

#设置架构
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")

#设置依赖
#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6)")

#设置description
SET(CPACK_PACKAGE_DESCRIPTION "pro-cc service")

#设置联系方式
SET(CPACK_PACKAGE_CONTACT "support@pro.com")

#设置维护人
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "PikachuHy")
# 设置支持指定安装目录的控制为 ON                                   
#set(CPACK_SET_DESTDIR ON)
# 设置安装到的目录路径
#set(CPACK_INSTALL_PREFIX "/home/vesoft/install") 
#set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/home")
#list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/home/vesoft")
# 设置安装前执行的脚本文件 preinst
#set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/preinst)
# 设置卸载前执行的脚本文件 prerm
#set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/prerm)
# 设置安装后执行的脚本文件 postinst
#set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst)
# 设置卸载后执行的脚本文件 postrm
#set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/postrm)

INSTALL(TARGETS App  Mylib
        RUNTIME DESTINATION /usr/local/bin
	#LIBRARY DESTINATION /usr/local/lib    # 通常，编译器只会在 </usr/lib> 和 </lib> 中找头文件，如果
        #ARCHIVE DESTINATION /tmp/cmake_demo    # 将库文件放在其他目录，可能会引起找不到库文件错误
        )


include (CPack)
